package de.wepner.texteditor.model;

import de.wepner.texteditor.model.event.Event;


public class EditorData {
    
    public static final String NEW_FILE_COMMAND = "file.new";
    public static final String LOAD_FILE_COMMAND = "file.load";
    public static final String SAVE_FILE_COMMAND = "file.save";
    public static final String SAVE_FILE_AS_COMMAND = "file.saveAs";
    public static final String EXIT_APPLICATION_COMMAND = "application.exit";
    public static final String UNDO_COMMAND = "file.undo";
    public static final String REDO_COMMAND = "file.redo";
    public static final String ABOUT_COMMAND = "application.about";
    
    public static final String[] ALL_COMMANDS = new String[] { EditorData.NEW_FILE_COMMAND,
            EditorData.LOAD_FILE_COMMAND, EditorData.SAVE_FILE_COMMAND, EditorData.SAVE_FILE_AS_COMMAND,
            EditorData.EXIT_APPLICATION_COMMAND, EditorData.UNDO_COMMAND, EditorData.REDO_COMMAND,
            EditorData.ABOUT_COMMAND };
    
    private EditedFile editedFile;
    
    private final Event<EditorData, EditedFile> editedFileChanged = new Event<EditorData, EditedFile>(this);
    public final Event<EditorData, EditedFile>.EventAccessor onEditedFileChanged = this.editedFileChanged.accessor;
    
    public final Event<EditorData, Integer> closeEditor = new Event<EditorData, Integer>(this);
    
    public final CommandMapping commands = new CommandMapping();
    
    public void setEditedFile(EditedFile editedFile) {
        this.editedFile = editedFile;
        
        this.editedFileChanged.fireEvent(this.editedFile);
    }
    
    public EditedFile getEditedFile() {
        return this.editedFile;
    }
}
